package kr.hkit.powerjava.chapter22.submit3;
//챕터 22 프로그래밍7번 
import java.util.HashSet;

class Lotto {
	private HashSet<Integer> arrNum;

	public Lotto(HashSet<Integer> arrNum) {
		this.arrNum = arrNum;
	}

	public int getNum() { //숫자 받기
		return ((int) (Math.random() * 45) + 1);
	}
	
	public boolean search(int s) { //중복검색
		if (arrNum.contains(s)) { //중복값 있으면 true
			return true;
		} else {
			return false;
		}
	}
	
	public void prnArr() { //출력
		for (int i = 0; arrNum.size() < 6 ; i++) {
			if (search(getNum())) {
				i--;
			} else {
				arrNum.add(getNum());
			}
		}
		System.out.println(arrNum);
	}
}


public class LottoTest {
	public static void main(String[] args) {

		HashSet<Integer> s1 = new HashSet<>();
		Lotto l = new Lotto(s1);
		l.prnArr();
	
	}
}
